import { login } from '@/api/user'

export default {
  namespaced: true,
  state: {
    token: ''
  },
  mutations: {
    updateToken(state, token) {
      // 往state中存入token
      state.token = token
    }
  },

  actions: {
    // 发送ajax
    async doAxios(context, loginForm) {
      const res = await login(loginForm)
      console.log(res)
      context.commit('updateToken', res.data)
    }
  }
}
